import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";

var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2;

import React from 'react';
import { Modal, Table, Form, Button, Input, Row, Col } from 'antd';
import { Bind } from 'lodash-decorators';
import intl from 'utils/intl';
import { isTenantRoleLevel, tableScrollWidth } from 'utils/utils';
import { SEARCH_FORM_ITEM_LAYOUT, SEARCH_FORM_ROW_LAYOUT, FORM_COL_4_LAYOUT } from 'utils/constants';
import Lov from 'components/Lov';
/**
 * GroupModal-选择新的用户组 弹框
 * @reactProps {Boolean} visible 模态框是否显示
 * @reactProps {Boolean} dataSource 用户组的数据源
 * @reactProps {Function(selectedRows:Object[]):Promise|*} onSave 确认按钮的回调,接收选中的用户组,返回一个Promise对象或者任意值
 * @reactProps {Function} onCancel 取消按钮的回调
 */

var GroupModal = (_dec = Form.create({
  fieldNameProp: null
}), _dec2 = Bind(), _dec3 = Bind(), _dec4 = Bind(), _dec5 = Bind(), _dec(_class = (_class2 = /*#__PURE__*/function (_React$Component) {
  _inherits(GroupModal, _React$Component);

  var _super = _createSuper(GroupModal);

  function GroupModal() {
    _classCallCheck(this, GroupModal);

    return _super.apply(this, arguments);
  }

  _createClass(GroupModal, [{
    key: "handleReset",
    value: function handleReset() {
      var resetFields = this.props.form.resetFields;
      resetFields();
    }
  }, {
    key: "handleCancel",
    value: function handleCancel() {
      var onCancel = this.props.onCancel;
      onCancel();
    }
  }, {
    key: "handleSearch",
    value: function handleSearch() {
      var _this$props = this.props,
          onSearch = _this$props.onSearch,
          form = _this$props.form;
      form.validateFields(function (_, value) {
        onSearch(value);
      });
    }
  }, {
    key: "handleTableChange",
    value: function handleTableChange(pagination) {
      var _this$props2 = this.props,
          onTableChange = _this$props2.onTableChange,
          form = _this$props2.form;
      form.validateFields(function (_, value) {
        onTableChange(_objectSpread({
          page: pagination
        }, value));
      });
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props3 = this.props,
          visible = _this$props3.visible,
          dataSource = _this$props3.dataSource,
          pagination = _this$props3.pagination,
          form = _this$props3.form,
          fetchEmployeeLoading = _this$props3.fetchEmployeeLoading;
      var columns = [!isTenantRoleLevel() && {
        title: intl.get('ciam.subAccount.model.employee.tenantName').d('租户名称'),
        dataIndex: 'tenantName'
      }, {
        title: intl.get('ciam.subAccount.model.employee.employeeName').d('员工名称'),
        dataIndex: 'employeeName',
        width: 200
      }, {
        title: intl.get('ciam.subAccount.model.employee.employeeNum').d('员工编码'),
        dataIndex: 'employeeNum'
      }].filter(Boolean);
      return /*#__PURE__*/React.createElement(Modal, {
        visible: visible,
        wrapClassName: "ant-modal-sidebar-right",
        transitionName: "move-right",
        onCancel: this.handleCancel,
        width: 720,
        title: intl.get('ciam.subAccount.view.message.title.employee').d('查看员工'),
        footer: null
      }, /*#__PURE__*/React.createElement(Form, {
        className: "more-fields-search-form"
      }, /*#__PURE__*/React.createElement(Row, Object.assign({
        type: "flex",
        align: "bottom",
        gutter: 24
      }, SEARCH_FORM_ROW_LAYOUT), !isTenantRoleLevel() && /*#__PURE__*/React.createElement(Col, FORM_COL_4_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, SEARCH_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.tenantMenu.tenantId').d('租户名称')
      }), form.getFieldDecorator('tenantId')( /*#__PURE__*/React.createElement(Lov, {
        code: "CPFM.TENANT"
      })))), /*#__PURE__*/React.createElement(Col, FORM_COL_4_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, SEARCH_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.tenantMenu.employeeName').d('员工姓名')
      }), form.getFieldDecorator('employeeName')( /*#__PURE__*/React.createElement(Input, null)))), /*#__PURE__*/React.createElement(Col, FORM_COL_4_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, SEARCH_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.tenantMenu.employeeNum').d('员工编码')
      }), form.getFieldDecorator('employeeNum')( /*#__PURE__*/React.createElement(Input, null)))), /*#__PURE__*/React.createElement(Col, Object.assign({}, FORM_COL_4_LAYOUT, {
        className: "search-btn-more"
      }), /*#__PURE__*/React.createElement(Form.Item, null, /*#__PURE__*/React.createElement(Button, {
        onClick: this.handleReset
      }, intl.get('cpaas.common.button.reset').d('重置')), /*#__PURE__*/React.createElement(Button, {
        type: "primary",
        htmlType: "submit",
        onClick: this.handleSearch
      }, intl.get('cpaas.common.button.search').d('查询')))))), /*#__PURE__*/React.createElement(Table, {
        bordered: true,
        rowKey: "employeeId",
        loading: fetchEmployeeLoading,
        dataSource: dataSource,
        pagination: pagination,
        columns: columns,
        style: {
          marginTop: 14
        },
        scroll: {
          x: tableScrollWidth(columns)
        },
        onChange: this.handleTableChange
      }));
    }
  }]);

  return GroupModal;
}(React.Component), (_applyDecoratedDescriptor(_class2.prototype, "handleReset", [_dec2], Object.getOwnPropertyDescriptor(_class2.prototype, "handleReset"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleCancel", [_dec3], Object.getOwnPropertyDescriptor(_class2.prototype, "handleCancel"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleSearch", [_dec4], Object.getOwnPropertyDescriptor(_class2.prototype, "handleSearch"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleTableChange", [_dec5], Object.getOwnPropertyDescriptor(_class2.prototype, "handleTableChange"), _class2.prototype)), _class2)) || _class);
export { GroupModal as default };